package com.atguigu.binarysearch;


/**
 * @author xgc
 * @create 2021-07-22 10:30.
 * 饿汉式（立即加载）
 */
public class Singleton1 {
    //私有构造
    private Singleton1(){
        System.out.println("构造函数Singleton1");
    }

    //初始值为实例对象
    private static Singleton1 singleton = new Singleton1();

    // 静态工厂方法
    public static Singleton1 getInstance(){
        System.out.println("getInstance");
        return singleton;
    }

    public static void main(String[] args) {
        System.out.println("初始化");
        Singleton1 instance = Singleton1.getInstance();
    }

}
